load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "controllers",
    srcs = [
        "config_converter.go",
        "etcd_cluster.go",
        "etcd_controller.go",
        "github_controller.go",
        "helper.go",
        "ingress_controller.go",
        "probe.go",
        "proxy.go",
        "proxy_controller.go",
        "rbac.go",
    ],
    importpath = "go.f110.dev/heimdallr/pkg/k8s/controllers",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/cert",
        "//pkg/config",
        "//pkg/config/configv2",
        "//pkg/k8s/api/etcd",
        "//pkg/k8s/api/etcd/v1alpha2",
        "//pkg/k8s/api/proxy",
        "//pkg/k8s/api/proxy/v1alpha2",
        "//pkg/k8s/client/versioned",
        "//pkg/k8s/client/versioned/scheme",
        "//pkg/k8s/controllers/controllerbase",
        "//pkg/k8s/informers/externalversions",
        "//pkg/k8s/k8sfactory",
        "//pkg/k8s/listers/etcd/v1alpha2",
        "//pkg/k8s/listers/monitoring/v1:monitoring",
        "//pkg/k8s/listers/proxy/v1alpha2",
        "//pkg/logger",
        "//pkg/netutil",
        "//pkg/rpc",
        "//pkg/version",
        "//vendor/cloud.google.com/go/storage",
        "//vendor/github.com/bradleyfalzon/ghinstallation",
        "//vendor/github.com/google/go-cmp/cmp",
        "//vendor/github.com/google/go-github/v41/github",
        "//vendor/github.com/jetstack/cert-manager/pkg/apis/certmanager",
        "//vendor/github.com/jetstack/cert-manager/pkg/apis/certmanager/v1:certmanager",
        "//vendor/github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2",
        "//vendor/github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha3",
        "//vendor/github.com/jetstack/cert-manager/pkg/apis/certmanager/v1beta1",
        "//vendor/github.com/minio/minio-go/v7:minio-go",
        "//vendor/github.com/minio/minio-go/v7/pkg/credentials",
        "//vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1:monitoring",
        "//vendor/github.com/prometheus/client_model/go",
        "//vendor/github.com/prometheus/common/expfmt",
        "//vendor/go.etcd.io/etcd/api/v3/etcdserverpb",
        "//vendor/go.etcd.io/etcd/client/v3:client",
        "//vendor/go.etcd.io/etcd/etcdutl/v3/snapshot",
        "//vendor/go.uber.org/zap",
        "//vendor/golang.org/x/xerrors",
        "//vendor/google.golang.org/api/iterator",
        "//vendor/google.golang.org/api/option",
        "//vendor/k8s.io/api/apps/v1:apps",
        "//vendor/k8s.io/api/batch/v1:batch",
        "//vendor/k8s.io/api/core/v1:core",
        "//vendor/k8s.io/api/networking/v1:networking",
        "//vendor/k8s.io/api/policy/v1:policy",
        "//vendor/k8s.io/api/rbac/v1:rbac",
        "//vendor/k8s.io/apimachinery/pkg/api/errors",
        "//vendor/k8s.io/apimachinery/pkg/api/meta",
        "//vendor/k8s.io/apimachinery/pkg/api/resource",
        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:meta",
        "//vendor/k8s.io/apimachinery/pkg/labels",
        "//vendor/k8s.io/apimachinery/pkg/runtime",
        "//vendor/k8s.io/apimachinery/pkg/selection",
        "//vendor/k8s.io/apimachinery/pkg/util/intstr",
        "//vendor/k8s.io/client-go/informers",
        "//vendor/k8s.io/client-go/kubernetes",
        "//vendor/k8s.io/client-go/listers/apps/v1:apps",
        "//vendor/k8s.io/client-go/listers/core/v1:core",
        "//vendor/k8s.io/client-go/listers/networking/v1:networking",
        "//vendor/k8s.io/client-go/rest",
        "//vendor/k8s.io/client-go/tools/cache",
        "//vendor/k8s.io/client-go/tools/portforward",
        "//vendor/k8s.io/client-go/transport/spdy",
        "//vendor/k8s.io/client-go/util/retry",
        "//vendor/sigs.k8s.io/yaml",
    ],
)

load("@dev_f110_rules_k8s_controller//k8s:def.bzl", "rbac_gen")

rbac_gen(
    name = "rbac",
    srcs = [":controllers"],
    controller_tools_version = "v0.5.0",
    dir = "operator/config/rbac",
    rolename = "heimdallr",
    visibility = ["//visibility:public"],
)

go_test(
    name = "controllers_test",
    srcs = [
        "config_converter_test.go",
        "etcd_cluster_test.go",
        "etcd_controller_test.go",
        "github_controller_test.go",
        "ingress_controller_test.go",
        "main_test.go",
        "proxy_controller_test.go",
        "proxy_test.go",
        "runner_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":controllers"],
    deps = [
        "//pkg/config",
        "//pkg/config/configv2",
        "//pkg/k8s/api/etcd",
        "//pkg/k8s/api/etcd/v1alpha2",
        "//pkg/k8s/api/proxy",
        "//pkg/k8s/api/proxy/v1alpha2",
        "//pkg/k8s/client/versioned/fake",
        "//pkg/k8s/controllers/controllertest",
        "//pkg/k8s/informers/externalversions",
        "//pkg/k8s/k8sfactory",
        "//pkg/logger",
        "//vendor/github.com/google/go-cmp/cmp",
        "//vendor/github.com/jarcoal/httpmock",
        "//vendor/github.com/jetstack/cert-manager/pkg/apis/certmanager/v1:certmanager",
        "//vendor/github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2",
        "//vendor/github.com/stretchr/testify/assert",
        "//vendor/github.com/stretchr/testify/require",
        "//vendor/go.etcd.io/etcd/api/v3/etcdserverpb",
        "//vendor/go.etcd.io/etcd/client/v3:client",
        "//vendor/golang.org/x/xerrors",
        "//vendor/gopkg.in/yaml.v2:yaml_v2",
        "//vendor/k8s.io/api/apps/v1:apps",
        "//vendor/k8s.io/api/core/v1:core",
        "//vendor/k8s.io/api/networking/v1:networking",
        "//vendor/k8s.io/api/policy/v1:policy",
        "//vendor/k8s.io/api/rbac/v1:rbac",
        "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:meta",
        "//vendor/k8s.io/apimachinery/pkg/runtime",
        "//vendor/k8s.io/client-go/informers",
        "//vendor/k8s.io/client-go/kubernetes/fake",
        "//vendor/k8s.io/client-go/listers/core/v1:core",
        "//vendor/k8s.io/client-go/scale/scheme",
        "//vendor/k8s.io/client-go/testing",
        "//vendor/k8s.io/client-go/tools/cache",
        "//vendor/k8s.io/gengo/namer",
        "//vendor/k8s.io/gengo/types",
        "//vendor/sigs.k8s.io/yaml",
    ],
)
